# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         copy和deepcopy
# Description:
# Author:       asus
# Date:         2019/3/5
#-------------------------------------------------------------------------------


#copy方法和deepcopy函数
#定义一个字典
person1 = {"Name":"Bill","age":30,"fullName":["Bill","Gates"]}
#浅复制copy
person2 = person1.copy()
print("person1",person1)
print("person2",person2)
print("------浅复制------")
print("------修改第1层元素------")
person2['age'] = 54
#输出person1看看是否改变
print("person1",person1)
print("person2",person2)
print("------修改第2层元素------")
person2["fullName"] [1] = "Clinton"
#输出person1已经改变
print("person1",person1)
print("person2",person2)
print("------深层复制------")
from copy import deepcopy
person1 = {"Name":"Bill","age":30,"fullName":["Bill","Gates"]}
#person2为浅复制
person2 = person1.copy()
#person3为深层复制
person3 = deepcopy(person1)
#修改原字典的第二层元素
person1["fullName"] [1] = "Clinton"
print("person1",person1)
print("person2",person2)
print("person3",person3)


